<?php 
include 'headers.php';
include 'fileOperations.php';
include 'functions.php';
?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="css/bootstrap.css" rel="stylesheet">
		<link href ="css/bootstrap-responsive.css" rel="stylesheet">
		<link href ="css/moje.css" rel="stylesheet">
        <title></title>
    </head>
    <body>
        <?php
        //var_dump($_POST['email']);
        //var_dump($_POST['pass']);
         if(isset($_POST['email']) and isset($_POST['pass']))
         {
             $tekst=openFile($_POST['email']);
             
             if($tekst[1]==$_POST['pass'])
               {
               $_SESSION['logged']=true;
               $_SESSION['email']=$_POST['email'];
               $_SESSION['name']=$tekst[0];
               
               }
                       
             setcookie('email', $_SESSION['email'], time()+3600);
             setcookie('logged', $_SESSION['logged'], time()+3600);
             loginFunction();
         }
         elseif( isset($_COOKIE['email']) and isset($_COOKIE['logged']))
         {
             
             $_SESSION['email'] = $_COOKIE['email'];
             $_SESSION['logged'] = $_COOKIE['logged'];
             loginFunction();
         }
        ?>
    </body>
</html>